package com.mr.qa.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import com.mr.qa.exception.QaException;

public class DateUtil {

	public static Date StringToDate(String strDate, String dateFormat) throws QaException{
		SimpleDateFormat format = new SimpleDateFormat(dateFormat);
		try{
			return format.parse(strDate);
		}catch(ParseException e){
			throw new QaException(e);
		}
	}
	
	public static String dateToString(Date date, String dateFormat){
		SimpleDateFormat format = new SimpleDateFormat(dateFormat);
		return format.format(date);
	}
	
	public static void main(String[] args) throws Exception{
		Calendar calNow = Calendar.getInstance();
		calNow.add(Calendar.DATE, 8);
		System.out.println(DateUtil.dateToString(calNow.getTime(), "yyyy-MM-dd HH:mm:ss"));
	}
}
